
DEPRECATED!

DEPRECATED!

DEPRECATED!

DEPRECATED!



<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<script type="text/javascript">
		var documentData = <%out.print(request.getAttribute("documentData"));%>;
		var availableStatuses = <%out.print(request.getAttribute("availableStatuses"));%>;
		var availableDocTypes = <%out.print(request.getAttribute("availableDocTypes"));%>;
	</script>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
	<title>Document</title>
	<style>
		body {
			background-color: AliceBlue ;
		}
		input {
			width: 80%;
		}
		.frame {
			border-style:solid;
			border-width:1px;
			border-color:LightSteelBlue;

			padding: 5px;
			display: inline-block;
			/*clear: none;*/
			float: left;
			margin: 5px;
			background-color: white;
		}
		#header {			
			width: 882px;
		}
		#menu {			
			width: 280px;
			clear: none;
			
		}
		#info {
			width: 580px;
			clear: none;
			
		}
		#container {
			min-width: 920px;
			width: 900px;
			
			margin-left:auto;
			margin-right:auto;
		}
		.bold {
			font-weight: bold;
		}
	</style>
	
	<script src="js/jquery-1.10.1.js"></script>
	
	<script>
	/*
	function getInputTextField(label, name, value) {
		//if value==null... value = "";
		var template = label + ":<br/> <input type=\"text\" name=\"" +
		name + "\" + value=\"" +
		value + "\"><br/><br/>";
		return template;
	}
	function getDropdownList(label, name, options, selectedValue) {
		var optionsList = "";
		for(var i = 0; i < options.length; i = i + 1) {
			var selected = "";
			if(options[i]==selectedValue) {
				selected = "selected";
			}
			optionsList += "<option value=\""+ options[i] +"\" "+ selected +">"+ options[i] +"</option>";
		}
		var template = label + ":<br/><select name=\"" + name + "\">" +
		optionsList +
		"<select><br/><br/>";
		return template;
	}
	*/
	String.format = function() {
		  var s = arguments[0];
		  for (var i = 0; i < arguments.length - 1; i++) {       
		    var reg = new RegExp("\\{" + i + "\\}", "gm");             
		    s = s.replace(reg, arguments[i + 1]);
		  }
		  return s;
	}
	
	$(document).ready(function () {
			var template = "";
			for(var i = 0; i < availableStatuses.length; i = i+1) {
				template += "<option value=\"" + availableStatuses[i].value + "\">" + availableStatuses[i].text + "</option>";
			}
			$("#status").append(template);
			
			
			
			/*for every json-object*/
			
			for(var i = 0; i < documentData.length; i = i+1) {
	
				
				
				/*if current json-object is a set of standard attributes, set these attributes*/
	
				if(documentData[i].dataType=="common") {
					//set all common fields
					
					$("#type").text("tut dolzhen byt' tip dokumenta");
					$("#description").attr('value', documentData[i].description);
					$("#name").attr('value', documentData[i].name);
					$("#status").children().each(function() {
					    if($(this).attr("value")==documentData[i].status) {
					    	$(this).attr('selected','');
					    };
					});
				
					
					
				/*if current json-object is a single attribute, generate and append an attribute*/	
				
				} else {
					var template = "";
					
					
					
					/*attribute is a text field*/
					
					if(documentData[i].type=="textfield") {
						template = "{0}:<br/><input id=\"{0}\" type=\"text\" name=\"{0}\" value=\"{1}\"><br/><br/>";
					
						if(documentData[i].value==null){
							documentData[i].value = "";
						}
						$("#form").append(String.format(template, documentData[i].lable, documentData[i].value));
						
						
						
					/*attribute is a dropdown-list*/
						
					} else if(documentData[i].type=="select") {
						template = String.format("{0}:<br/><select id=\"select{1}\">", documentData[i].lable, i);
						for(var j = 0; j < documentData[i].values.length; j = j+1) {
							
							var option = "<option value=\"{0}\"";
							if(documentData[i].values[j].value == documentData[i].value) {
								option += " selected ";
							}
							option += ">{1}</option>";
							
							template += String.format(option, documentData[i].values[j].value, documentData[i].values[j].text);
						}
						template += "</select><br/><br/>";
						$("#form").append(String.format(template, documentData[i].value));
					}					
				}
			}
	});
	</script>
</head>
<body>
<div id="container">

<div id="header" class="frame">
<h1>Header</h1>

</div>

<div id="menu" class="frame">
<h2>Menu</h2>
catalog :<br/>
<span id="catalog" class="bold">Some catalog</span><br/><br/>

</div>

<div id="info" class="frame">
<h2>Info</h2>
<form id="form">

type:<br/>
<span id="type" class="bold">Some document type</span><br/><br/>

status:<br/>
<select id="status" name="status">
</select><br/><br/>

name:<br/>
<input id="name" type="text" name="name"><br/><br/>

description:<br/>
<input id="description" type="text" name="description"><br/><br/>

created :<br/>
<span id="created" class="bold">11/11/1111</span><br/><br/>

created by:<br/>
<span id="created_by" class="bold">Ivan Ivanov</span><br/><br/>

updated :<br/>
<span id="updated" class="bold">11/11/1111</span><br/><br/>

updated by:<br/>
<span id="updated_by" class="bold">Bazil Pupkin</span><br/><br/>

</form> 
</div>
</div>
</body>
</html>